<!DOCTYPE html>
<html>

<head>
    <title>{$Think.config.app_name}</title>
    {include file="public/head"/}
    <style>
        textarea {
            resize: none;
            overflow: hidden;
            border: 1px solid #ddd;
            font-size: 12px;
            color: #999;
            width: 100px;
        }

        .textarea {
            resize: none;
            padding: 2px 5px !important;
        }
    </style>
</head>

<body class="layui-layout-body">
    <div id="LAY_app" class="layadmin-tabspage-none">
        <div class="layui-layout layui-layout-admin">
            {include file="public/menu"/}
            <!-- 主体内容 -->
            <div class="layui-body root_box" v-cloak>
                <div class="layui-form layui-border-box">
                    <div class="layui-table-tool">
                        <div class="layui-form">
                            <div class="layui-input-inline">
                                <button type="button" class="layui-btn layui-btn-primary layui-btn-sm">访问统计表</button>
                            </div>
                        </div>
                    </div>
                    <div class="layui-table-box">
                        <div class="layui-table-body layui-table-main">
                            <table cellspacing="0" cellpadding="0" border="0" class="layui-table" width="100%">
                                <thead>
                                    <tr>
                                        <th>
                                            <div class="layui-table-cell "><span>节点ID</span>
                                            </div>
                                        </th>
                                        <th>
                                            <div class="layui-table-cell "><span>节点名称</span>
                                            </div>
                                        </th>
                                        <th>
                                            <div class="layui-table-cell"><span>节点地址</span>
                                            </div>
                                        </th>
                                        <th>
                                            <div class="layui-table-cell"><span>访问次数</span>
                                            </div>
                                        </th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr v-show="list.length==0">
                                        <td class="nodata" colspan="12">{{nomoredata}}</td>
                                    </tr>
                                    <tr v-show="list.length>0" v-for="(item, index) in list" :key="index">
                                        <td>
                                            <div class="layui-table-cell">{{item.node_id}}</div>
                                        </td>
                                        <td>
                                            <div class="layui-table-cell">{{item.node_title}}</div>
                                        </td>
                                        <td>
                                            <div class="layui-table-cell">
                                                /{{item.node_module}}/{{item.node_controller}}/{{item.node_action}}
                                            </div>
                                        </td>
                                        <td>
                                            <div class="layui-table-cell">{{item.visitcount}}</div>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <div class="layui-table-page">
                        <a class="layui-btn layui-btn-primary layui-btn-xs">访问日志清理后，访问统计将被重置</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
{include file="public/foot"/}
<script>
    var app = new Vue({
        el: ".root_box",
        data: {
            list: [],
            nomoredata: "数据加载中",
            //上面的参数不允许删除
        },
        created: function () {
            this.getList();
        },
        methods: {
            urldecode: function (e) {
                return decodeURIComponent(e);
            },
            isSelected: function (conf_id) {
                return this.selectList.indexOf(conf_id) >= 0 ? true : false;
            },
            time2string: function (timestamps) {
                return new Date(parseInt(timestamps) * 1000).Format("MM-dd hh:mm");
            },
            sort: function (e) {
                this.order[0] = e.target.attributes.skey.value;
                this.order[1] = e.target.attributes.title.value == "升序" ? 'asc' : 'desc';
                this.getList();
            },
            prev: function () {
                this.current_page--;
                this.getList();
            },
            next: function () {
                this.current_page++;
                this.getList();
            },
            getList: function () {
                this.isSelectedAll = false;
                this.selectList = [];
                _loading();
                $.post("/api/log/state", Object.assign({
                }, PostCommon),
                    function (data, status) {
                        _hideLoading();
                        if (data.code != 200) {
                            if (data.url) {
                                location.replace(data.url);
                            }
                            _alert(data.msg);
                            app.nomoredata = data.msg;
                        } else {
                            app.list = data.data;
                        }
                    });
            },
        }
    });

    function select(primary_key) {
        var primary_key = parseInt($(primary_key).attr('primary_key'));
        console.log(primary_key);
        if (app.selectList.indexOf(primary_key) >= 0) {
            app.selectList.splice(app.selectList.indexOf(primary_key), 1);
        } else {
            app.selectList.push(primary_key);
        }
        console.log(JSON.parse(JSON.stringify(app.selectList)));
    }

    function selectALL() {
        app.selectList = [];
        if (!app.isSelectedAll) {
            app.list.forEach(function (value, index) {
                app.selectList.push(value.conf_id);
            });
        }
        app.isSelectedAll = !app.isSelectedAll;
    }
</script>

</html>